//===============================
//  功能 ：备注 
//  作者 ：上中野辅亚瑟王 
//  创建时间 ：2023-05-30  15-27-58 
//  Unity版本  ：2019.4.35f1 
//  变更时间 :  2023-05-30  15-27-58 
//===============================





using UnityEngine;

namespace ZS.U3D.BASE.Runtime.Singleton
{
    public class SingletonInstance<T> where T:class,ISingleton
    {
        private static T _instance;
        public static T Instance {
            get {
                if (_instance==null)
                {
                    Debug.LogError($"{typeof(T)} is not create");
                }
                return _instance;
            }
        }

        protected SingletonInstance()
        {
            if (_instance != null)
                throw new System.Exception($"{typeof(T)} instance already created.");
            _instance = this as T;
        }

        protected void DestroyInstance()
        {
            _instance = null;
        }
    }
}
